package client

import (
	"context"
	"github.com/micro/go-micro/v2/client"
	"github.com/micro/go-micro/v2/client/grpc"

	"kop/framework/wrapper"
	"kop/pb"
	"kop/pb/service"
)

type qType int32

var ActivityService service.ActivityService

const (
	Login         qType = 1  //
	Event         qType = 2  //
	Coin          qType = 3  //
	Gold          qType = 4  //
	Diamond       qType = 5  //
	CaptainTalent qType = 6  //
	Power         qType = 7  //
	Train         qType = 8  //
	Conquer       qType = 9  //
	Intimacy      qType = 10 //
	Income        qType = 11 //
	GuildExp      qType = 12 //
)

func init() {

	var c = grpc.NewClient(client.Wrap(wrapper.ClientLogWrapper))
	_ = c.Init()

	//s.Init(test.Flags()...)

	ActivityService = service.NewActivityService("go.micro.srv.activity", c)

}

func AddPoints(roleID, serverID int32, Type qType, n int64) {

	if n != 0 {
		go ActivityService.AddPoints(context.Background(), &service.ActivityPointsRequest{RoleID: roleID, ServerID: serverID, Type: int32(Type), Points: n})
	}
}

func AddGuildPoints(guild *pb.Guild, Type qType, n int32) {
	ActivityService.AddGuildPoints(context.Background(), &service.GuildPointsRequest{Guild: guild, Type: int32(Type), Points: int64(n)})
}

//func SetPoints(roleID, serverID int32, Type qType, n int64) {
//
//	go ActivityService.SetPoints(context.Background(), &service.ActivityPointsRequest{RoleID: roleID, ServerID: serverID, Type: int32(Type), Points: n})
//}
